<template>
  <div class="box">
    <div class="head">
      <!-- 搜索框 -->
      <van-search
        v-model="value"
        shape="round"
        background="#fff"
        placeholder="请输入搜索关键词"
      >
        <template #left>
          <van-icon
            name="arrow-left"
            color="#333"
            size="25px"
            style="margin-right: 10px"
          />
        </template>
      </van-search>
    </div>
    <!-- 商品分类 -->
    <div class="cates">
      <van-tree-select
        height="100%"
        :items="items"
        :main-active-index.sync="active"
      >
        <template #content>
          <!-- <van-image
            v-if="active === 0"
            src="https://img01.yzcdn.cn/vant/apple-1.jpg"
          /> -->
          <div class="list-item" v-if="active === 0">
            <p>热门分类</p>
            <van-grid :column-num="3">
              <van-grid-item
                :border="false"
                icon-size="70px"
                v-for="item in hotList"
                :key="item.id"
                :icon="item.src"
                :text="item.name"
              />
            </van-grid>
          </div>
          <div class="list-item" v-if="active === 1">
            <p>热门品牌</p>
            <van-grid :column-num="3">
              <van-grid-item
                :border="false"
                icon-size="70px"
                v-for="item in phoneList"
                :key="item.id"
                :icon="item.src"
                :text="item.name"
              />
            </van-grid>
            <p>手机通讯</p>
            <van-grid :column-num="3">
              <van-grid-item
                :border="false"
                icon-size="70px"
                v-for="item in phoneList"
                :key="item.id"
                :icon="item.src"
                :text="item.name"
              />
            </van-grid>
          </div>
          <div class="list-item" v-if="active === 2">
            <p>热门分类</p>
            <van-grid :column-num="3">
              <van-grid-item
                :border="false"
                icon-size="70px"
                v-for="item in hotList"
                :key="item.id"
                :icon="item.src"
                :text="item.name"
              />
            </van-grid>
          </div>
          <div class="list-item" v-if="active === 3">
            <p>热门品牌</p>
            <van-grid :column-num="3">
              <van-grid-item
                :border="false"
                icon-size="70px"
                v-for="item in phoneList"
                :key="item.id"
                :icon="item.src"
                :text="item.name"
              />
            </van-grid>
            <p>手机通讯</p>
            <van-grid :column-num="3">
              <van-grid-item
                :border="false"
                icon-size="70px"
                v-for="item in phoneList"
                :key="item.id"
                :icon="item.src"
                :text="item.name"
              />
            </van-grid>
          </div>
          <div class="list-item" v-if="active === 4">
            <p>热门分类</p>
            <van-grid :column-num="3">
              <van-grid-item
                :border="false"
                icon-size="70px"
                v-for="item in hotList"
                :key="item.id"
                :icon="item.src"
                :text="item.name"
              />
            </van-grid>
          </div>
          <div class="list-item" v-if="active === 5">
            <p>热门品牌</p>
            <van-grid :column-num="3">
              <van-grid-item
                :border="false"
                icon-size="70px"
                v-for="item in phoneList"
                :key="item.id"
                :icon="item.src"
                :text="item.name"
              />
            </van-grid>
            <p>手机通讯</p>
            <van-grid :column-num="3">
              <van-grid-item
                :border="false"
                icon-size="70px"
                v-for="item in phoneList"
                :key="item.id"
                :icon="item.src"
                :text="item.name"
              />
            </van-grid>
          </div>
          <div class="list-item" v-if="active === 6">
            <p>热门分类</p>
            <van-grid :column-num="3">
              <van-grid-item
                :border="false"
                icon-size="70px"
                v-for="item in hotList"
                :key="item.id"
                :icon="item.src"
                :text="item.name"
              />
            </van-grid>
          </div>
          <div class="list-item" v-if="active === 7">
            <p>热门品牌</p>
            <van-grid :column-num="3">
              <van-grid-item
                :border="false"
                icon-size="70px"
                v-for="item in phoneList"
                :key="item.id"
                :icon="item.src"
                :text="item.name"
              />
            </van-grid>
            <p>手机通讯</p>
            <van-grid :column-num="3">
              <van-grid-item
                :border="false"
                icon-size="70px"
                v-for="item in phoneList"
                :key="item.id"
                :icon="item.src"
                :text="item.name"
              />
            </van-grid>
          </div>
          <div class="list-item" v-if="active === 8">
            <p>热门分类</p>
            <van-grid :column-num="3">
              <van-grid-item
                :border="false"
                icon-size="70px"
                v-for="item in hotList"
                :key="item.id"
                :icon="item.src"
                :text="item.name"
              />
            </van-grid>
          </div>
          <div class="list-item" v-if="active === 9">
            <p>热门品牌</p>
            <van-grid :column-num="3">
              <van-grid-item
                :border="false"
                icon-size="70px"
                v-for="item in phoneList"
                :key="item.id"
                :icon="item.src"
                :text="item.name"
              />
            </van-grid>
            <p>手机通讯</p>
            <van-grid :column-num="3">
              <van-grid-item
                :border="false"
                icon-size="70px"
                v-for="item in phoneList"
                :key="item.id"
                :icon="item.src"
                :text="item.name"
              />
            </van-grid>
          </div>
          <div class="list-item" v-if="active === 10">
            <p>热门分类</p>
            <van-grid :column-num="3">
              <van-grid-item
                :border="false"
                icon-size="70px"
                v-for="item in hotList"
                :key="item.id"
                :icon="item.src"
                :text="item.name"
              />
            </van-grid>
          </div>
          <div class="list-item" v-if="active === 11">
            <p>热门品牌</p>
            <van-grid :column-num="3">
              <van-grid-item
                :border="false"
                icon-size="70px"
                v-for="item in phoneList"
                :key="item.id"
                :icon="item.src"
                :text="item.name"
              />
            </van-grid>
            <p>手机通讯</p>
            <van-grid :column-num="3">
              <van-grid-item
                :border="false"
                icon-size="70px"
                v-for="item in phoneList"
                :key="item.id"
                :icon="item.src"
                :text="item.name"
              />
            </van-grid>
          </div>
          <div class="list-item" v-if="active === 12">
            <p>热门分类</p>
            <van-grid :column-num="3">
              <van-grid-item
                :border="false"
                icon-size="70px"
                v-for="item in hotList"
                :key="item.id"
                :icon="item.src"
                :text="item.name"
              />
            </van-grid>
          </div>
          <div class="list-item" v-if="active === 13">
            <p>热门品牌</p>
            <van-grid :column-num="3">
              <van-grid-item
                :border="false"
                icon-size="70px"
                v-for="item in phoneList"
                :key="item.id"
                :icon="item.src"
                :text="item.name"
              />
            </van-grid>
            <p>手机通讯</p>
            <van-grid :column-num="3">
              <van-grid-item
                :border="false"
                icon-size="70px"
                v-for="item in phoneList"
                :key="item.id"
                :icon="item.src"
                :text="item.name"
              />
            </van-grid>
          </div>
          <div class="list-item" v-if="active === 14">
            <p>热门分类</p>
            <van-grid :column-num="3">
              <van-grid-item
                :border="false"
                icon-size="70px"
                v-for="item in hotList"
                :key="item.id"
                :icon="item.src"
                :text="item.name"
              />
            </van-grid>
          </div>
          <div class="list-item" v-if="active === 15">
            <p>热门品牌</p>
            <van-grid :column-num="3">
              <van-grid-item
                :border="false"
                icon-size="70px"
                v-for="item in phoneList"
                :key="item.id"
                :icon="item.src"
                :text="item.name"
              />
            </van-grid>
            <p>手机通讯</p>
            <van-grid :column-num="3">
              <van-grid-item
                :border="false"
                icon-size="70px"
                v-for="item in phoneList"
                :key="item.id"
                :icon="item.src"
                :text="item.name"
              />
            </van-grid>
          </div>
          <div class="list-item" v-if="active === 16">
            <p>热门分类</p>
            <van-grid :column-num="3">
              <van-grid-item
                :border="false"
                icon-size="70px"
                v-for="item in hotList"
                :key="item.id"
                :icon="item.src"
                :text="item.name"
              />
            </van-grid>
          </div>
        </template>
      </van-tree-select>
    </div>
  </div>
</template>

<script>
// import { Notify } from "vant";
import listInfo from "./listinfo.js";
export default {
  data() {
    return {
      value: "",
      // 热门导航栏
      hotNav: listInfo.goodsHot,
      // 热门推荐图片
      hotList: listInfo.goodsHotInfo,
      // 手机
      phoneList: listInfo.phoneInfo,

      active: 0,
      items: [
        { text: "热门推荐" },
        { text: "手机数码" },
        { text: "京东超市" },
        { text: "家用电器" },
        { text: "电脑办公" },
        { text: "玩具乐器" },
        { text: "家居厨具" },
        { text: "家具家装" },
        { text: "男装" },
        { text: "男鞋" },
        { text: "女装" },
        { text: "女鞋" },
        { text: "美妆护肤" },
        { text: "医药保健" },
        { text: "酒水饮料" },
        { text: "运动户外" },
      ],
    };
  },
};
</script>

<style scoped>
.van-search {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 99;
  width: 100%;
}
.box {
  position: relative;
  overflow: hidden;
}
.cates {
  height: 80%;
}
.van-sidebar {
  margin-top: 54px;
}
.van-tree-select__nav {
  flex-grow: 0;
  flex-shrink: 1;
  flex-basis: 100px;
  overflow-y: auto;
  background-color: #f7f8fa;
  -webkit-overflow-scrolling: touch;
}
.van-tree-select__content {
  position: absolute;
  width: 310px;
  height: 100%;
  top: 54px;
  right: 0;
}
.list-item p {
  margin: 10px;
  font-size: 14px;
  color: #333;
  padding-left: 5px;
}
.list-item ::v-deep i.van-icon.van-grid-item__icon {
  font-size: 70px;
}
</style>